﻿<Window x:Class="ListOfTale.AuthorForm"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="Список авторов" Height="300" Width="500" xmlns:my="clr-namespace:ListOfTale" Loaded="Window_Loaded">
    <Window.Resources>
        <my:TalesDataSet x:Key="talesDataSet" />
        <CollectionViewSource x:Key="authorViewSource" Source="{Binding Path=Author, Source={StaticResource talesDataSet}}" />
    </Window.Resources>
    <Grid DataContext="{StaticResource authorViewSource}">

        <Grid.RowDefinitions>
            <RowDefinition Height="100*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <DataGrid AutoGenerateColumns="False" SelectionMode="Extended" EnableRowVirtualization="True"  HorizontalAlignment="Stretch" ItemsSource="{Binding}" Name="authorDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch" >
            <DataGrid.ContextMenu>
                <ContextMenu  >
                    <MenuItem Header="Объединить" Click="MenuItem_Click"/>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="nameColumn" Header="ФИО" Width="300" Binding="{Binding Name}"  >
                </DataGridTextColumn>
                <DataGridTextColumn x:Name="authorIdColumn" Binding="{Binding Path=AuthorId}" Header="Author Id" Width="SizeToHeader" Visibility="Collapsed"/>
            </DataGrid.Columns>
        </DataGrid>
        <Grid Grid.Row="1">
            <Button Height="30" Width="125" HorizontalAlignment="Left" Click="Button_Click_2">
                Добавить
            </Button>
            <Button Height="30" Width="125" HorizontalAlignment="Center" Click="Button_Click_1">
                Редактировать
            </Button>
            <Button Height="30" Width="125" HorizontalAlignment="Right" Click="Button_Click">
                Удалить
            </Button>
        </Grid>
    </Grid>
</Window>
